package com.sunny.miaosha.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sunny.miaosha.dao.UserDao;
import com.sunny.miaosha.domain.User;

@Service
public class UserService {
	
	@Autowired
	private UserDao userDao; 
	
	public User getById(int id) {
		return userDao.getById(id);
	}
	
	@Transactional
    public Boolean dbTx() {
    	User user1 = new User(1, "alice");
    	User user2 = new User(2, "jone");
    	userDao.insert(user2);
    	userDao.insert(user1);
    	return true;
    }
}
